package com.kungfuhacking.wristbandpro.find;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.kungfuhacking.wristbandpro.R;
import com.kungfuhacking.wristbandpro.base.view.BaseFragment;
import com.kungfuhacking.wristbandpro.custom.MyItemView;
import com.kungfuhacking.wristbandpro.find.activity.CustomerServiceActivity;
import com.kungfuhacking.wristbandpro.find.activity.IDConfirmeActivity;
import com.kungfuhacking.wristbandpro.find.activity.QuestionnaireActivity;
import com.kungfuhacking.wristbandpro.my.activity.AddOldActivity;
import com.kungfuhacking.wristbandpro.net.ApiService;

/**
 * 发现fragment
 * Created by Aaron on 17/5/25.
 */

public class FragmentFind extends BaseFragment implements View.OnClickListener {

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View findView = inflater.inflate(R.layout.fragment_find, null);
        initWidget(findView);

        return findView;

    }

    private void initWidget(View view) {
        MyItemView mivadd = (MyItemView) view.findViewById(R.id.miv_add);
        MyItemView mividconfirm = (MyItemView) view.findViewById(R.id.miv_id_confirm);
//        MyItemView mivnewpackage = (MyItemView) view.findViewById(R.id.miv_new_package);
        MyItemView mivcharge = (MyItemView) view.findViewById(R.id.miv_charge);
//        MyItemView mivorderlist = (MyItemView) view.findViewById(R.id.miv_order_list);
        MyItemView mivdonate = (MyItemView) view.findViewById(R.id.miv_donate);
        MyItemView mivquestionnaire = (MyItemView) view.findViewById(R.id.miv_questionnaire);
        MyItemView mivcustomerservice = (MyItemView) view.findViewById(R.id.miv_customer_service);

        mivadd.setOnClickListener(this);
        mividconfirm.setOnClickListener(this);
//        mivnewpackage.setOnClickListener(this);
        mivcharge.setOnClickListener(this);
//        mivorderlist.setOnClickListener(this);
        mivdonate.setOnClickListener(this);
        mivquestionnaire.setOnClickListener(this);
        mivcustomerservice.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {

            case R.id.miv_add://添加老人
                Bundle b = new Bundle();
                b.putBoolean("cancle", true);
                nextActivityWithBundle(AddOldActivity.class, b);
                break;

            case R.id.miv_id_confirm://实名认证
                nextActivity(IDConfirmeActivity.class);
                break;

//            case R.id.miv_new_package://新开套餐
//                nextActivity(NewSimActivity.class);
//                break;

            case R.id.miv_charge://话费充值

                Intent intent= new Intent();
                intent.setAction("android.intent.action.VIEW");
                Uri content_url = Uri.parse(ApiService.CHARGE_PAGE);
                intent.setData(content_url);
                nextActivityWithIntent(intent);

//                nextActivity(PayWebActivity.class);
                break;

//            case R.id.miv_order_list://订单列表
//                nextActivity(OrderListActivity.class);
//                break;

            case R.id.miv_donate://捐赠

                Intent mIntent= new Intent();
                mIntent.setAction("android.intent.action.VIEW");
                Uri cont_url = Uri.parse(ApiService.DONATE);
                mIntent.setData(cont_url);
                nextActivityWithIntent(mIntent);

                break;

            case R.id.miv_questionnaire://问卷调查
                nextActivity(QuestionnaireActivity.class);
                break;

            case R.id.miv_customer_service://客服中心
                nextActivity(CustomerServiceActivity.class);
                break;
        }

    }
}
